<?php 
header("Content-type: text/html; charset=utf-8");
if($_GET['op']=="add" && $_POST['encode']=="defasfewqTeqfdcvxcxV,fwrfdafadsfda4323445")
{
	if($_POST['pass22']=="a4a123456")
	{
		require('../lib/functions.php');
		require('../lib/mySQL.php');
		require('../configs/config.php');
		$gWeb = new Web();
		$INCOME = $gWeb->parse_incoming();
		$DB = new DB;
		$DB->info['host'] = $CONF['db_host'];
		$DB->info['usr']  = $CONF['db_user'];
		$DB->info['pwd']  = $CONF['db_pass'];
		$DB->info['db']   = $CONF['db_db'];
		$DB->db_connect();
		if($INCOME['email'])
		{
			$r = $DB->db_query_first("select * from admin_info where name='".$INCOME['email']."'");
			if($r)
			{
				echo "<script>alert('保存失败，原因 已经存在');history.go(-1);</script>";
			}
			else
			{
				$f['com'] = $INCOME['com'];
				//$f[''] = $INCOME['code'];
				$f['comShort'] = $INCOME['comShort'];
				$f['realName'] = $INCOME['dealerP'];
				$f['cryFuzeren'] = $INCOME['klsler'];
				$f['cryFuzerenEmail'] = $INCOME['dealerEmail'];
				$f['address'] = $INCOME['addr'];
				$f['name'] = $INCOME['email'];
				$f['email'] = $INCOME['email'];
				$f['mima'] = $INCOME['pass'];
				$f['pass'] = md5($INCOME['pass']);
				$f['addTime'] = date("Y-m-d H:i:s");
				$f['roleId'] = $INCOME['roleId'];
				$f['roleName'] = $INCOME['roleName'];
				$DB->db_form_insert("admin_info",$f);
				echo "<script>alert('保存成功');</script>";
			}
		}
	}
	else
	{
		echo "<script>alert('保存失败，原因 操作密码不正确');history.go(-1);</script>";
	}
}
?>
<!doctype html>
<html>
<head>
<script src="../js/jquery/jquery-1.8.2.js"></script>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<style>
body{font-size:12px;}
input{width:400px}
</style>
<body>
<form id="form" method="post" action="addUser.php?op=add">
<table>
<tr><td width="100">公司名称</td><td><input name="com" type="text"/></td></tr>
<tr><td>经销商Code号</td><td><input name="code" type="text"/></td></tr>
<tr><td>经销商简称</td><td><input name="comShort" type="text"/></td></tr>
<tr><td>账户负责人</td><td><input name="dealerP" type="text"/></td></tr>
<tr><td>账户负责人邮件</td><td><input name="dealerEmail" type="text"/></td></tr>
<tr><td>地址</td><td><input name="addr" type="text"/></td></tr>
<tr><td>克莱斯勒负责人</td><td><input name="klsler" type="text"/></td></tr>
<tr><td>开通账户邮件地址</td><td><input name="email" type="text"/></td></tr>
<tr><td>账户密码</td><td><input name="pass" type="text"/></td></tr>
<tr><td></td><td></td></tr>
<tr><td>账户类型</td><td><select name="roleId" onchange="$('#roleName').val($(this).find('option:selected').text());"><option value="3">下载</option><option value="4">审批</option><option value="2">上传</option></select>&nbsp;
&nbsp;如果是经销商账号 请选 [下载]&nbsp;&nbsp;//&nbsp;&nbsp;如果是JEEP客户  选 [审批]&nbsp;&nbsp;//&nbsp;&nbsp;如果是agency 选 [上传]&nbsp;&nbsp;&nbsp;&nbsp;如有特殊情况按客户意思选择</td></tr>

<tr><td>操作密码</td><td><input name="pass22" type="text"/></td></tr>
<tr><td colspan="2"><input type="button" style="width:200px" value="提交" id="btn"/></td></tr>
<input type="hidden" name="encode" value="defasfewqTeqfdcvxcxV,fwrfdafadsfda4323445"/>
<input type="hidden" id="roleName" name="roleName" value="下载"/>
</table>
</form>
<script>
$(function(){
	$("#btn").click(function()
	{
        var canSubmit = true;
        
		$("#form").find("input").each(function(){
         if(this.value=="")
         {
        	 canSubmit=false;
        	 return;
         }
		});
		if(canSubmit)
		{
			$("#form")[0].submit();
		}
		else
		{
			alert("所有项都必填");
		}
	});
	
});
</script>
</body>
</html>
